import React, { Component } from 'react';
import { StyleSheet, View, Text } from 'react-native';

import { SafeAreaView } from 'react-navigation';

import BaseStyle from '../constants/Style';

import Swt from '../components/switch';

export default class SwitchScreen extends Component {
  constructor(props) {
    super(props);
    this.state = {
      value: true,
      ChangeText: '开关切换',
    };
  }

  render() {
    return (
      <SafeAreaView
        style={[BaseStyle.flex, styles.homebg]}
        forceInset={{ top: 'never' }}>
        <View style={styles.container}>
          <Text style={styles.text}>{this.state.ChangeText}</Text>
          <View style={styles.swt}>
          <Swt
            value={this.state.value}
            disabled={false}
            onTintColor={'green'} //打开时的背景色
            thumbTintColor={'#fff'} //圆形按钮的背景色
            tintColor={'#fff'} //关闭时的边框颜色(iOS)或者背景颜色(Android)。
            onValueChange={value => {
              this.setState({
                value: value,
                ChangeText: value ? '开关打开了' : '开关关闭了',
              });
            }}
          />
          </View>
        </View>
      </SafeAreaView>
    );
  }
}

const styles = StyleSheet.create({
  homebg: {
    backgroundColor: '#eee',
  },
  container: {
    ...BaseStyle.flex,
    paddingTop: 20,
    paddingLeft: 30,
  },
  text: {
    marginBottom: 30,
  },
  swt:{
    ...BaseStyle.row,
    justifyContent:"flex-start"
  },
});
